﻿using Max.PH4_2102A.Shopping.DAL;
using Max.PH4_2102A.Shopping.Domain;
using Max.PH4_2102A.Shopping.IRespository;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Max.PH4_2102A.Shopping.Respository
{
    /// <summary>
    /// 订单主表的仓储实现
    /// </summary>
    public class OrderMasterRespository : IOrderMasterRespository
    {
        EFCoreHelper _ef;

        public OrderMasterRespository(EFCoreHelper ef)
        {
            _ef = ef;
        }

        public IQueryable<OrderMasterEntity> GetAll()
        {
            return _ef.OrderMasters;
        }

        public void Insert(OrderMasterEntity entity)
        {
            _ef.OrderMasters.Add(entity);
        }
    }


    /// <summary>
    /// 订单明细表的仓储实现
    /// </summary>
    public class OrderDetailRespository : IOrderDetailRespository
    {
        EFCoreHelper _ef;

        public OrderDetailRespository(EFCoreHelper ef)
        {
            _ef = ef;
        }

        public IQueryable<OrderDetailEntity> GetAll()
        {
            return _ef.OrderDetails;
        }

        public void Insert(OrderDetailEntity entity)
        {
            _ef.OrderDetails.Add(entity);
        }

        public void Insert(List<OrderDetailEntity> entities)
        {
            _ef.OrderDetails.AddRange(entities);
        }
    }
}
